<?php

namespace App\Http\Controllers\Admin;

use App\Models\Admin\AdminMenu;
use App\Models\Admin\AdminUser;
use Illuminate\Support\Facades\Hash;
use Illuminate\View\View;

class IndexController extends BaseController
{

    public function index(): View
    {
        $menuList = AdminMenu::get()->toArray();
        $res = [
            'menu_list' => get_tree($menuList)
        ];
        return view('admin.index.index', $res);
    }

    public function dashboard(): View
    {
        $res = [
            'cpu_usage' => sys_getloadavg(),
            'current_usage' => round(memory_get_usage() / 1024 / 1024, 2),
        ];
        return view('admin.index.dashboard', $res);
    }

    private function getMenuList(): array
    {
        $menuList = AdminMenu::get()->toArray();
        return get_tree($menuList);
    }

}
